﻿<navigation:Page x:Class="ShopOnline.Views.ViewProducts" 
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           mc:Ignorable="d"      
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           xmlns:local="clr-namespace:ShopOnline"
           d:DesignWidth="777" d:DesignHeight="290"
           Title="ViewProducts Page" xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit" xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk">
    <UserControl.Resources>
        <local:ConvertSelectionToBool x:Key="BoolConverter" />
    </UserControl.Resources>
    <toolkit:BusyIndicator Name="busyIndicator">
        <Grid x:Name="LayoutRoot">
            <TextBlock Height="23" HorizontalAlignment="Left" Margin="12,12,0,0" 
                       Text="Filter by:" VerticalAlignment="Top" />
            <ComboBox Height="23" HorizontalAlignment="Left" Margin="69,8,0,0" 
                    Name="comboBoxCategories" VerticalAlignment="Top" Width="120" />
            <Button Content="Filter" Height="23" HorizontalAlignment="Left" Margin="195,8,0,0" 
                    Name="buttonFilter" VerticalAlignment="Top" Width="75"
                    IsEnabled="{Binding ElementName=comboBoxCategories, Mode=TwoWay, Path=SelectedItem,
                    Converter={StaticResource BoolConverter}}" Click="buttonFilter_Click" />
            <TextBlock Height="23" HorizontalAlignment="Left" Margin="12,41,0,0" Name="textBlockResult" 
                       Text="" VerticalAlignment="Top" />
            <sdk:DataGrid AutoGenerateColumns="False" Height="145" HorizontalAlignment="Left" Margin="12,70,0,0"
                          Name="dataGridProducts" VerticalAlignment="Top" Width="456" >
                <sdk:DataGrid.Columns>
                    <sdk:DataGridTextColumn Header="Product name" Binding="{Binding ProductName}" IsReadOnly="True"/>
                    <sdk:DataGridTextColumn Header="Category" Binding="{Binding Category.CategoryName}" IsReadOnly="True"/>
                    <sdk:DataGridTextColumn Header="Description" Binding="{Binding Description}" IsReadOnly="True"/>
                    <sdk:DataGridTextColumn Header="Price" Binding="{Binding Price, StringFormat=c}" IsReadOnly="True" />
                    <sdk:DataGridTemplateColumn Width="80">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Button Name="ButtonAddToCart" Content="Add to cart" Width="70" Height="20"
                                        Click="buttonAddToCart_Click"></Button>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                </sdk:DataGrid.Columns>
            </sdk:DataGrid>
            <sdk:DataPager Height="26" HorizontalAlignment="Left" Margin="12,221,0,0" Name="dataPagerProducts" 
                           PageSize="10" VerticalAlignment="Top" Width="456" />
            <sdk:DataGrid AutoGenerateColumns="False" Height="145" HorizontalAlignment="Left" Margin="474,70,0,0" 
                          Name="dataGridCart" VerticalAlignment="Top" Width="284">
                <sdk:DataGrid.Columns>
                    <sdk:DataGridTextColumn Header="Product name" Binding="{Binding ProductName}" IsReadOnly="True"/>
                    <sdk:DataGridTextColumn Header="Quantity" Binding="{Binding Ammount, Mode=TwoWay}" IsReadOnly="True"                                            />
                    <sdk:DataGridTemplateColumn Width="80">
                        <sdk:DataGridTemplateColumn.CellTemplate>
                            <DataTemplate>
                                <Button Name="ButtonRemove" Content="Remove" Width="70" Height="20"
                                        Click="ButtonRemove_Click"></Button>
                            </DataTemplate>
                        </sdk:DataGridTemplateColumn.CellTemplate>
                    </sdk:DataGridTemplateColumn>
                </sdk:DataGrid.Columns>                
            </sdk:DataGrid>
            <TextBlock Height="23" HorizontalAlignment="Left" Margin="474,224,0,0" Name="textBlock" 
                       Text="Total:" VerticalAlignment="Top" />
            <TextBox Height="23" HorizontalAlignment="Left" Margin="513,220,0,0" Name="textBoxTotal" 
                     VerticalAlignment="Top" Width="77" IsReadOnly="True" />
            <Button Content="Order" Height="23" HorizontalAlignment="Left" Margin="683,220,0,0" 
                    Name="buttonOrder" VerticalAlignment="Top" Width="75" Click="buttonOrder_Click" />
            <Button Content="Clear cart" Height="23" HorizontalAlignment="Left" Margin="602,220,0,0" 
                    Name="buttonClear" VerticalAlignment="Top" Width="75" Click="buttonClear_Click" />
        </Grid>
    </toolkit:BusyIndicator>        
</navigation:Page>
